<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="com.sz.message.bmo.IMessageBMO" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String requestUrl = request.getRequestURL().toString();

String style1 = "font-size:12px; width:80px";


String ticket_id = request.getParameter("ticket_id");
String telno = request.getParameter("telno");
String type = request.getParameter("type");
if(type == null || type.length() == 0) {
	type = "1";  //默认是1
}

String tip = request.getParameter("tip"); //上次发送的返回提示
if(tip == null) tip = "";

String sms = "";
if(ticket_id != null && ticket_id.length() > 0) {
	ServletContext servletContext = request.getSession().getServletContext(); 
	ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
	IMessageBMO message = (IMessageBMO) context.getBean("MessageBMO");
	sms = message.getSMS_Ticket(ticket_id, type);
}

%>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		
		<base href="<%=basePath%>">

		<title>短信</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="addAnnounce_business">
		<meta http-equiv="description" content="短信">

	</head>
	
	<body onload="onLoad()">  	

	<form id="form" name="form" action="sendSMS.exec" method="post">
 	<table width="100%" border="1">
  		<tr>
	  		<td style="<%=style1%>">电话号码&nbsp;</td>
	  		<td>
	  			<input id="telno" name="telno" type="text" value="<%=telno%>" style="width:120px">
	  		</td>
	  		
	  		<td style="<%=style1%>">短信类型&nbsp;</td>
	  		<td style="font-size:12px">
	  			<select id="type" name="type" onchange="onChange(this.value)">
	  				<option value="1">预定成功</option>
	  				<option value="2">请柬短信</option>
	  				<option value="3">预定失败</option>
	  				<option value="4">就餐提醒</option>
	  			</select>
	  		</td>
		</tr>
		
		<tr>
			<td colspan="4">
				<textarea id="sms" name="sms" style="width:400px; height:100px"><%=sms%></textarea>
			</td>
		</tr>		
  	</table>
  	<input type="hidden" id="re_url" name="re_url" value="<%=requestUrl%>">
  	<input type="hidden" id="ticket_id" name="ticket_id" value="<%=ticket_id%>">
  	</form>
  	
  	<br/>
  	
  	<table width="100%" >
  		<tr align="center">
  			<td>
  				<input type="button" value="发送" onclick="onSendSMS()"/>
  			</td>
  		</tr>
  	</table>
  	
  	<SCRIPT LANGUAGE="JavaScript">
  		function onLoad() {
  			var type = "<%=type%>";
  			var obj = document.getElementById("type");
  			for(var i = 0; i < obj.options.length; ++i) {
  				var cur = obj.options[i];
  				if(cur.value == type) {
  					cur.selected = true;
  					break;
  				}  				
  			}
  			
  			//显示上次的发送结果
  			var tip = "<%=tip%>";
  			if(tip != "") {
  				alert(tip);
  			}
  			
  		}
  		function onChange(value) {
  			var url = "<%=requestUrl%>";
  			url += "?ticket_id=" + "<%=ticket_id%>";
  			url += "&telno=" + "<%=telno%>";
  			url += "&type=" + value;
  			window.location.href = url;
  		}
  		function onSendSMS() {
  			var obj = document.getElementById("form");
  			obj.submit();
  		}
  	</SCRIPT>
	</body>
</html>
